package org.csu.mypetstore.exception;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.NonNull;
import org.springframework.web.servlet.HandlerInterceptor;

public class CartInterceptor implements HandlerInterceptor
{
    @Override
    public boolean preHandle(HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) throws Exception
    {
        if (request.getSession().getAttribute("username") == null)
            response.sendRedirect("/account/loginView");
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }
}
